package 测试;

public class 字符串替换 {

	public static void main(String[] args) {

	}

}

class StringFormat {
	public String formatString(String A, int n, char[] arg, int m) {
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;
		for (i = 0; i < n - 1; i++) {
			if (A.charAt(i) == '%' && A.charAt(i + 1) == 's') {
				sb.append(arg[j++]);
				i++;
			} else {
				sb.append(A.charAt(i));
			}
		}
		if (A.charAt(n - 2) != '%' || A.charAt(n - 1) != 's') {
			sb.append(A.charAt(n - 1));
		}
		while (j < m) {
			sb.append(arg[j++]);
		}
		return sb.toString();
	}
}